package com.acwing.www;

/**
 * Creared with IntelliJ IDEA.
 * Description:二分算法
 * User:yxd
 * Date:2022-01-11
 * Time:0:33
 */
import java.util.*;
public class Dichotomy{
    static int N = 100005;
    static int[] p = new int[N];
    static int n,q;
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        n = input.nextInt();
        q = input.nextInt();
        for(int i = 0;i < n; i ++){
            p[i] = input.nextInt();
        }
        //二分模板
        while(q-- != 0){
            int k = input.nextInt();
            int l = 0;
            int r = n - 1;
            while(l < r) {
                int mid = l + r >> 1;//先放在中间
                if(p[mid] >= k) r = mid;//如果mid的值比k还大说明答案在左半边
                else l = mid + 1;
            }
            if(p[l] != k){//此时找到的是出现k 的最小下标  如果最后的值不是k说明没有这个值
                System.out.print("-1 -1");
            }else{
                System.out.print(l + " ");
                l = 0;
                r = n - 1;
                while(l < r){
                    int mid = l + r + 1 >> 1;//由于是找左半边的如果l = r - 1  不加一 的话就会出现死循环
                    if(p[mid] <= k) l = mid;//如果mid的值比k还小说明答案在右半边
                    else r = mid - 1;
                }

                System.out.print(r);//再输出出现这个值的最大下标
            }

            System.out.println();

        }

    }
}